package com.hjm.project.qbMcc.qbMcc.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.qbMcc.qbMcc.domain.QbMcc;
import com.hjm.project.qbMcc.qbMcc.service.IQbMccService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 钱宝_mccController
 * 
 * @author LOVE
 * @date 2020-11-28
 */
@Controller
@RequestMapping("/qbMcc/qbMcc")
public class QbMccController extends BaseController
{
    private String prefix = "qbMcc/qbMcc";

    @Autowired
    private IQbMccService qbMccService;

    @RequiresPermissions("qbMcc:qbMcc:view")
    @GetMapping()
    public String qbMcc()
    {
        return prefix + "/qbMcc";
    }

    /**
     * 查询钱宝_mcc列表
     */
    @RequiresPermissions("qbMcc:qbMcc:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QbMcc qbMcc)
    {
        startPage();
        List<QbMcc> list = qbMccService.selectQbMccList(qbMcc);
        return getDataTable(list);
    }

    /**
     * 导出钱宝_mcc列表
     */
    @RequiresPermissions("qbMcc:qbMcc:export")
    @Log(title = "钱宝_mcc", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QbMcc qbMcc)
    {
        List<QbMcc> list = qbMccService.selectQbMccList(qbMcc);
        ExcelUtil<QbMcc> util = new ExcelUtil<QbMcc>(QbMcc.class);
        return util.exportExcel(list, "qbMcc");
    }

    /**
     * 新增钱宝_mcc
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存钱宝_mcc
     */
    @RequiresPermissions("qbMcc:qbMcc:add")
    @Log(title = "钱宝_mcc", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QbMcc qbMcc)
    {
        return toAjax(qbMccService.insertQbMcc(qbMcc));
    }

    /**
     * 修改钱宝_mcc
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        QbMcc qbMcc = qbMccService.selectQbMccById(id);
        mmap.put("qbMcc", qbMcc);
        return prefix + "/edit";
    }

    /**
     * 修改保存钱宝_mcc
     */
    @RequiresPermissions("qbMcc:qbMcc:edit")
    @Log(title = "钱宝_mcc", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QbMcc qbMcc)
    {
        return toAjax(qbMccService.updateQbMcc(qbMcc));
    }

    /**
     * 删除钱宝_mcc
     */
    @RequiresPermissions("qbMcc:qbMcc:remove")
    @Log(title = "钱宝_mcc", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qbMccService.deleteQbMccByIds(ids));
    }
}
